<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        用户名：<input type="text" class="username">
    </div>
    <div>
        密码：<input type="password" class="password">
    </div>
    <button disabled class="btn">提交</button>
    <script>
        var btnEle = document.querySelector('.btn')
        var passwordEle = document.querySelector('.password')
        var usernameEle = document.querySelector('.username')
        var passwordFlag = false
        var nameFlag = false
        passwordEle.onblur = function(){
            var length = this.value.length
            passwordFlag = length>=8
            btnEle.disabled = !(nameFlag&&passwordFlag)
        }
        usernameEle.onblur = function(){
            var length = this.value.length
            nameFlag = length>=3
            btnEle.disabled = !(nameFlag&&passwordFlag)
        }
    </script>
</body>
</html>